/**
AbstractNoSqlEntity.java
jackysoft-basic-core
2012-8-6下午5:59:48
@author 屈甲康
@QQ285799123
mailto:qujiakang@126.com
 **/
package org.jackysoft.entity.nosql;

import org.bson.types.ObjectId;
import org.jackysoft.annotations.Id;
import org.jackysoft.annotations.NoUpdate;
import org.jackysoft.entity.base.AbstractRootEntity;


public abstract class AbstractNoSqlEntity extends AbstractRootEntity  {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1075283436101166815L;
	
	@NoUpdate
	public ObjectId id = new ObjectId();
    
	public String bid;
  
	
	@Id
	public String getId() {		
		return bid!=null?bid:(id!=null?id.toString():null);
	}

	public ObjectId ObjectId(){return id;}
	
	public void setId(String id) {
		if(ObjectId.isValid(id)) 
			this.id = new ObjectId(id);
		else
			bid = id;
	}
	
	
}
